package com.cmsz.cashier.mapper;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.env.Environment;
import com.zaxxer.hikari.HikariConfig;
import com.zaxxer.hikari.HikariDataSource;

@Configuration
public class DataSourceConfiguration {

	@Autowired
	Environment env;
	
	@Bean
	public HikariDataSource datasource() {
		HikariConfig hikariConfig = new HikariConfig();
		hikariConfig.setDriverClassName(env.getProperty("datasource.driver"));
		hikariConfig.setJdbcUrl(env.getProperty("datasource.jdbcUrl2"));
		hikariConfig.setUsername(env.getProperty("datasource.user2"));
		hikariConfig.setPassword(env.getProperty("datasource.pass2.encrypt"));
		hikariConfig.setIdleTimeout(180);
		hikariConfig.setMaximumPoolSize(30);
		HikariDataSource dataSource = new HikariDataSource(hikariConfig);
		return dataSource;
	}
	
}
